
import java.util.ArrayList;
import java.util.List;

class Building {
    private final String name;
    
    public Building(String name) {
        this.name = name;
    }
    
    public String getName() {
        return name;
    }
}

class Course {
    private final String courseName;
    private final Building location;
    
    public Course(String courseName, Building location) {
        if (location == null) {
            throw new IllegalArgumentException("课程必须关联一个建筑");
        }
        this.courseName = courseName;
        this.location = location;
    }
    
    public Building getLocation() {
        return location;
    }
    
    public String getCourseName() {
        return courseName;
    }
}

class College {
    private final List<Building> buildings = new ArrayList<>();
    private final List<Course> courses = new ArrayList<>();
    
    public void addBuilding(Building building) {
        buildings.add(building);
    }
    
    public void addCourse(Course course) {
        courses.add(course);
    }
    
    public List<Building> getBuildings() {
        return new ArrayList<>(buildings);
    }
    
    public List<Course> getCourses() {
        return new ArrayList<>(courses);
    }
    
    public void clearCourses() {
        courses.clear();
    }
}

public class UniversityDemo {
    public static void main(String[] args) {
    
        Building mainBuilding = new Building("主楼");
        Building labBuilding = new Building("实验楼");
        
        College engineeringCollege = new College();
        

        engineeringCollege.addBuilding(mainBuilding);
        engineeringCollege.addBuilding(labBuilding);
        
        Course math101 = new Course("高等数学", mainBuilding);
        Course physics202 = new Course("大学物理", labBuilding);
        
        engineeringCollege.addCourse(math101);
        engineeringCollege.addCourse(physics202);
        

        System.out.println("课程 " + math101.getCourseName() + " 位于 " + 
                           math101.getLocation().getName());
        System.out.println("学院课程数: " + engineeringCollege.getCourses().size());
        System.out.println("学院建筑数: " + engineeringCollege.getBuildings().size());
        
        engineeringCollege.clearCourses();
        System.out.println("清理后学院课程数: " + engineeringCollege.getCourses().size());
    }
}